﻿using System;
using System.Collections.Generic; 
using System.Text;
using ATSIDAL;
using ATSModel;
using System.Data;
using System.Data.SqlClient;

namespace ATSDAL
{
    public class TPackRemarkDal : BaseRepository_DT<TPackaRemarkInfo>, ITPackRemark
    {

        #region 静态变量部分
        private const string PACK_ID = "@ID";
        private const string PACK_PCODERULEREMARK = "@PCodeRuleRemark"; 
        #endregion

        #region 数据检索部分

        /// <summary>
        /// 检索全部规则信息
        /// </summary>
        /// <returns></returns>
        public IList<TPackaRemarkInfo> LoadEntities()
        {
            return ExcuteSqlToGetEntities("sp_selTPackRemark");
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public IList<TPackaRemarkInfo> GetbyRemarkItem(int remarkItemId)
        {
            SqlParameter parm = new SqlParameter(PACK_ID, SqlDbType.Int);
            parm.Value = remarkItemId;
            return ExcuteSqlToGetEntities("sp_selTPackRemarkbyID", parm);
        }



        /// <summary>
        /// 根据ID 获取规则信息
        /// </summary>
        /// <typeparam name="T1"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        public TPackaRemarkInfo LoadEntity<T1>(T1 id)
        {
            SqlParameter parm = GetParameter();
            parm.Value = id;
            return ExcuteSqlToGetEntity("sp_selTPackRemarkbyID", parm);
        }

        #endregion

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override TPackaRemarkInfo GetEntityRecord(SqlDataReader rdr)
        {
            TPackaRemarkInfo rco = new TPackaRemarkInfo
            {
                Id= rdr.GetInt32(0),
                PCodeRuleRemark = rdr.GetValue(1).ToString() 
            };
            return rco;
        }

        public override TPackaRemarkInfo GetEntityRecord()
        {
            TPackaRemarkInfo pco = new TPackaRemarkInfo();
            return pco;
        }

        public override string GetInsertsp()
        {
            return "sp_InsertXXX";
        }

        public override string GetUpdatesp()
        {
            return "sp_UpdateXXX";
        }

        public override string GetDeletesp()
        {
            return "sp_DeleteXXXX";
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PACK_ID, SqlDbType.Int, 4);
            return Parm;
        }


        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
                    new SqlParameter(PACK_ID, SqlDbType.Int, 4),
					new SqlParameter(PACK_PCODERULEREMARK, SqlDbType.NVarChar, 1000) 
					 
                };
            return parms;
        }

        public override void SetParameters(TPackaRemarkInfo tPackRemark, params SqlParameter[] Parms)
        {
            Parms[0].Value = tPackRemark.Id;
            Parms[0].Value = tPackRemark.PCodeRuleRemark; 
        }
        #endregion  
 
    }
}
